package com.ita.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

import com.ita.vo.User;

@Component
@Aspect
public class PasswordAspect {

	@Around("execution(* com.ita.service.impl.UserServiceImpl.*(..))")
	public Object around(ProceedingJoinPoint pjp){
		System.out.println("aspect....");
		Object[] user=(Object[]) pjp.getArgs();
		User[] u=new User[user.length];
		
		String password=Md5Util.getMD5(((User) user[0]).getPassword());
		((User) user[0]).setPassword(password);
		u[0]=(User)user[0];
		
		System.out.println("加密："+password);
		 try {
			return pjp.proceed(u);
		} catch (Throwable e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}
}
